﻿using DevExpress.XtraEditors;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.Skins;
using System.Configuration;

namespace WinformDevelopFrame.UI
{
    public partial class FrmSkin : DevExpress.XtraEditors.XtraForm
    {
        private string skinName;
        public FrmSkin()
        {
            InitializeComponent();
        }

        private void FrmSkin_Load(object sender, EventArgs e)
        {
            skinName = DevExpress.LookAndFeel.UserLookAndFeel.Default.ActiveSkinName;
            comboBoxEdit1.EditValue=skinName;
            foreach (SkinContainer skin in DevExpress.Skins.SkinManager.Default.Skins)
            {
                comboBoxEdit1.Properties.Items.Add(skin.SkinName);
            }
        }

        private void simpleButton1_Click(object sender, EventArgs e)
        {
            skinName = comboBoxEdit1.EditValue.ToString();
            DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle(skinName); 
            Configuration configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            configuration.AppSettings.Settings["SkinName"].Value = skinName;
            configuration.Save(ConfigurationSaveMode.Modified);
            this.Close();
        }

        private void simpleButton2_Click(object sender, EventArgs e)
        {
            DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle(skinName);
            this.Close();
        }

        private void comboBoxEdit1_SelectedIndexChanged(object sender, EventArgs e)
        {
            DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle(comboBoxEdit1.EditValue.ToString());
        }
    }
}